﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Net.Mail;
using System.Net;

namespace BussinessLogic
{
    public enum ActivityType
    {
        Exercise,
        Questionnaire,
        MatrixExercise
    }

    public enum PictureType
    {
        Neutral,
        Negative
    }

    public static class Common
    {
        

        #region Password

        public static string HashPassword(string password)
        {
            byte[] byteRepresentation = UnicodeEncoding.UTF8.GetBytes(password);
            byte[] hashedTextInBytes = null;
            SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
            hashedTextInBytes = sha1.ComputeHash(byteRepresentation);
            return Convert.ToBase64String(hashedTextInBytes);
        }

        public static string CreateRandomPassword(int passwordLength)
        {
            string allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789!@$?";
            char[] chars = new char[passwordLength];
            Random rd = new Random();

            for (int i = 0; i < passwordLength; i++)
            {
                chars[i] = allowedChars[rd.Next(0, allowedChars.Length)];
            }

            return new string(chars);
        }
        #endregion
    }
}
